import time

from selenium import webdriver
from selenium.webdriver import ActionChains, Keys
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from selenium.webdriver.support.select import Select
from selenium.webdriver.support.wait import WebDriverWait

# 1.创建驱动对象
service = Service("C:/Program Files/Google/Chrome/Application/chromedriver.exe")
driver = webdriver.Chrome(service=service)

# 2.打开浏览器
driver.get("file:///C:/Users/82073/Desktop/pagetest/%E6%B3%A8%E5%86%8C%E5%AE%9E%E4%BE%8B.html")

# 1.在主页面的用户输入框中输入: admin
driver.find_element(By.ID, "userA").send_keys("admin")

time.sleep(1)
# 2.在注册用户A的用户输入框中输入：adminA
    # 切换到注册用户A页面中
# driver.switch_to.frame(driver.find_element(By.ID, "idframe1"))
# driver.switch_to.frame("myframe1")
driver.switch_to.frame("idframe1")
driver.find_element(By.ID, "userA").send_keys("adminA")

time.sleep(1)
# 3.返回主页面
driver.switch_to.default_content()

time.sleep(1)
# 4.在注册用户B的用户输入框中输入：adminB
    # 切换到注册用户B页面中
driver.switch_to.frame("idframe2")
driver.find_element(By.ID, "userA").send_keys("adminB")

# 5.返回主页面
driver.switch_to.default_content()

# 4.3s后关闭
time.sleep(3)

# 5.关闭驱动对象
driver.close()